package com.twu.biblioteca.ui;

import com.twu.biblioteca.data.Book;
import com.twu.biblioteca.data.BookDAO;
import com.twu.biblioteca.exceptions.BookNotCheckedOutException;

/**
 * Created by florian on 27/12/13.
 */
public class ReturnController extends ControllerWithBook {
    public ReturnController(ScreenControllerFactory controllerFactory, BibliotecaUI ui, BookDAO bookDAO) {
        super(controllerFactory, ui, bookDAO);
    }

    @Override
    protected void showUsage() {
        ui.showReturnMessage();
    }

    @Override
    protected ScreenController handleWithBook(Book book) throws BookNotCheckedOutException {
        bookDAO.returnBook(book);
        ui.showSuccessfulReturnMessage();
        return controllerFactory.createMainScreenController();
    }
    @Override
    protected ScreenController handleError() {
        ui.showUnsuccessfulReturnMessage();
        return this;
    }
}
